{# Used for MP and NS trees #}
{% extends "admin/change_list.html" %}
{% load admin_list admin_tree adminlte_list i18n %}

{% block extrastyle %}
{{ block.super }}
{% treebeard_css %}
{% endblock %}

{% block extrahead %}
{{ block.super }}
{% treebeard_js %}
{% endblock %}

{% block object-tools-items %}
<button id="exchange_menu" class="btn btn-danger">{% trans 'Exchange Menu' %}</button>
{{ block.super }}
{% endblock %}

{% block result_list %}
{% if action_form and actions_on_top and cl.full_result_count %}
{% admin_actions %}
{% endif %}
{% adminlte_result_tree cl request %}
{% if action_form and actions_on_bottom and cl.full_result_count %}
{% admin_actions %}
{% endif %}
{% endblock %}

{% block extrajs %}
{{ block.super }}
<script>
    $(function () {
        $('#exchange_menu').click(function () {
            $.get('{% url "admin:exchange_menu" %}', function (response) {
                console.log(response);
                if (response.message === 'success') {
                    window.location.reload();
                }
            })
        })
    });
</script>
{% endblock %}
